Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Update embed_url and trackable_embed_url modifiers to be valid with additional query strings #11265

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

martyf
Copy link
Contributor

@martyf martyf commented Dec 17, 2024

Youtube can attach new parameters when copying URLs, such as:
https://www.youtube.com/watch?v=xose4ruJXQ0&pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D

The embed_url and trackable_embed_url modifiers were incorrectly outputting the URL:
https://www.youtube-nocookie.com/embed/xose4ruJXQ0&pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D

This is not a valid URL, and will not play. It is missing the query string question mark.

However, the Video fieldtype does correctly embed the video - so the author would believe the video would embed correctly.

This PR updates these two modifiers to check that if an ampersand exists in the URL (i.e. there is more than one query string property) then there is also a question mark.

With this PR in place, the embedded URL will be:
https://www.youtube-nocookie.com/embed/xose4ruJXQ0?pp=ygUQaGFkZXN0b3duIGxvbmRvbg%3D%3D

Given users may not be technically minded, and may just copy-and-paste from YouTube, this is a quality of life improvement to reduce the chance of errors.

@jasonvarga jasonvarga merged commit 2e57c59 into statamic:5.x Dec 17, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants